﻿// 项目：	Guan.CMS.Model - Guan.CMS
// 文件名：	ProductCategoryInit.cs
// 
// 修改时间：2013-03-06 20:46
// 修改人：	Cooclsee

using System;
using Guan.CMS.Model.Entities;

namespace Guan.CMS.Data.Initialization
{
    public class ProductCategoryInit : CommonInit
    {
        public ProductCategoryInit(CmsDataContext context) : base(context)
        {
        }

        public void Init()
        {
            var parent1 = new ProductCategory {Name = "软件产品", IsPublished = true};
            var parent2 = new ProductCategory {Name = "硬件产品", IsPublished = true};
            this.Context.ProductCategories.Add(parent1);
            this.Context.ProductCategories.Add(parent2);
            this.Context.SaveChanges();
            const string level2 = "零售收银/批发/连锁;餐饮点菜/无线点菜FOR Android/ipad/itouch;美容/美发/沐足/瑜伽/会所/健身/汽车美容;移动POS/通联远程接入系统";
            foreach (var s in level2.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries))
            {
                var proC2 = new ProductCategory {Name = s, ParentId = parent1.Id, IsPublished = true};
                this.Context.ProductCategories.Add(proC2);
            }
            const string level3 = "商业POS收款机;餐饮点单收银触摸屏;餐饮无线点单设备;电脑/手机远程视频监控;条码扫描/条码打印/电子秤;票据打印机";
            foreach (var s in level3.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries))
            {
                var proC3 = new ProductCategory {Name = s, ParentId = parent2.Id, IsPublished = true};
                this.Context.ProductCategories.Add(proC3);
            }
            this.Context.SaveChanges();
        }
    }
}